<template>
	<c-base-page :current="2" :navText="'修改资料'">
		<view class="order-details">
			<uni-card class="detail-cards">
				<view class="detail-item">
					<view class="title">昵称:</view>
					<view class="desc">
						<input type="text" v-model="detailData.nickname" placeholder="请输入昵称" />
					</view>
				</view>
				<view class="detail-item">
					<view class="title">电话:</view>
					<view class="desc">
						<input type="text" v-model="detailData.phone" placeholder="请输入电话" />
					</view>
				</view>
				<view class="detail-item">
					<view class="title">原密码:</view>
					<view class="desc">
						<input type="password" v-model="detailData.oldPassword" placeholder="请输入原始密码" />
					</view>
				</view>
				<view class="detail-item">
					<view class="title">新密码:</view>
					<view class="desc">
						<input type="password" v-model="detailData.password" placeholder="请输入新密码" />
					</view>
				</view>
				<view class="detail-item">
					<view class="title">确认密码:</view>
					<view class="desc">
						<input type="password" v-model="detailData.surePassword" placeholder="请再次输入密码" />
					</view>
				</view>
				<view class="buttons">
					<button class="btn" type="primary" @click="_save">保 存</button>
				</view>
			</uni-card>
		</view>
	</c-base-page>
</template>

<script>
	export default {
		data() {
			return {
				detailData: {
					nickname: "ZSCN新能源",
					phone: "13681875258",
					oldPassword: "",
					password: "",
					surePassword: ""
				}
			}
		},
		onLoad(options) {
			
		},
		methods: {
			_save() {
				if (!this.detailData.nickname) {
					this.mxToast("请输入昵称!")
					return false
				} else if (!this.detailData.phone) {
					this.mxToast("请输入联系电话!")
					return false
				} else if (!/^.{4,20}$/.test(this.detailData.oldPassword)) {
					this.mxToast("请输入原始密码!")
					return false
				} else if (!/^.{4,20}$/.test(this.detailData.password)) {
					this.mxToast("请输入新密码!")
					return false
				} else if (this.detailData.password != this.detailData.surePassword) {
					this.mxToast("两次密码不一致!")
					return false
				}
				this.mxShowLoading()
				setTimeout(() => {
					this.mxToast("资料修改成功!")
					this.mxHideLoading()
				}, 2500)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.update-details {
		padding-bottom: 180rpx;
	}
	.detail-cards {
		.detail-item {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #666;
			padding: 20rpx 0;
			image {
				margin-right: 14rpx;
				width: 36rpx;
				height: 36rpx;
			}
			.title {
				font-weight: bold;
			}
			.desc {
				margin-left: 20rpx;
				flex: 1;
				overflow: hidden;
				text-align: right;
				font-size: 26rpx;
				border-bottom: 1px solid #eee;
				/deep/.input-placeholder {
					color: #a7a7a7;
				}
			}
		}
		.buttons {
			.btn {
				margin: 60rpx auto;
				background-color: #00aaff;
			}
		}
	}
</style>
